﻿//function document.oncontextmenu() { event.returnValue = false; } //屏蔽鼠标右键
//新增约场
var fnCustomAdd = function () {
    parent.addTabs('新增工作记录', '../Crm/Customer/EditCrmActivity.aspx?entity=CrmActivity');
    parent.NeedRefreshPage = this;
}


//编辑
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    parent.addTabs('编辑工作记录', '../Crm/Customer/EditCrmActivity.aspx?r=' + Math.random() + '&entity=CrmActivity&CLOSE=editRecord&cid=' + record.getData("CustomId") + '&id=' + record.getData(const_entityID));
    parent.NeedRefreshPage = this;
}
//双击事件
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    if (record == null) {
        alert("请选择一条记录");
        return;
    }
    parent.addTabs('编辑工作记录', '../Crm/Customer/EditCrmActivity.aspx?r=' + Math.random() + '&entity=CrmActivity&CLOSE=editRecord&cid=' + record.getData("CustomId") + '&id=' + record.getData(const_entityID));
    parent.NeedRefreshPage = this;
}
//格式化内容
var fnFormatText = function (elCell, oRecord, oColumn, sData) {
    if (sData.length > 30) {
        elCell.innerHTML = sData.substring(0, 30) + "...";
    }
    else {
        elCell.innerHTML = sData;
    }
};
//格式化备注
var fnFormatExplain = function (elCell, oRecord, oColumn, sData) {
    sData.replace("[BR]", "");
    if (sData.length > 30) {
        elCell.innerHTML = sData.substring(0, 30) + "...";
    }
    else {
        elCell.innerHTML = sData;
    }
};
//删除
var fnCustomDelete = function () {
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    dl = [];
    for (var i = 0; i < list.length; i++) {
        //this.getRecordSet()._records[0]._oData["BarItem"]
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
            dl.push(list[i]._sId); //获取行ID；
        }
    }
    if (elist.length == 0) {
        var recordID = myDataTable.getSelectedRows()[0];
        record = myDataTable.getRecord(recordID);
        if (editpageFlag == 0) {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=CrmActivity&id=" + record.getData(const_entityID);
        } else {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&table=CrmActivity&id=" + record.getData(const_entityID);
        }
    }
    else {
        if (editpageFlag == 0) {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&entity=CrmActivity&json=" + elist.join(",");
        }
        else {
            SaveUrl = "AjaxData/DataSave.aspx?r=" + Math.random() + "&action=delete&table=CrmActivity&json=" + elist.join(",");
        }
    }
    YAHOO.example.container.dialog3.show();
}
//$(document).ready(function () { //屏蔽右键
////    if (typeof (parent.unContextMenu) == "function") {
////        parent.unContextMenu(document);
////    }
////    if (typeof (parent.parent.unContextMenu) == "function") {
////        parent.parent.unContextMenu(document);
////    }
//});